﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataTier.Repository.Implementation
{
    class QueryContainer
    {

        #region StaticDataRepository queries
        /*
         private static readonly Func<SimplyEntities, Int32, Int32> GetBusinessCardCountForStyleQuery =
            CompiledQuery.Compile<SimplyEntities, Int32, Int32>((ctx, id) =>
                ctx.Product.Count(m => m is BusinessCard && m.Style.StyleId == id));

        private static readonly Func<SimplyEntities, Int32, Int32> GetBusinessCardCountForIndustryQuery =
            CompiledQuery.Compile<SimplyEntities, Int32, Int32>((ctx, id) =>
                ctx.Product.Count(m => m is BusinessCard && m.Industry.IndustryId == id));

        private static readonly Func<SimplyEntities, Int32, Int32> GetBusinessCardCountForColorQuery =
            CompiledQuery.Compile<SimplyEntities, Int32, Int32>((ctx, id) =>
                ctx.Product.Count(m => m is BusinessCard && m.ColorTheme.ColorThemeId == id));

        private static readonly Func<SimplyDataContext, Int32, FontDO> GetFontByIdQuery =
            CompiledQuery.Compile<SimplyDataContext, Int32, FontDO>((ctx, id) =>
                (from f in ctx.Fonts
                where f.FontId == id
                select new FontDO()
                {
                    Id = f.FontId,
                    FileName = f.FileName,
                    IsUnicode = f.IsUnicode,
                    LanguageCode = f.Language.Code,
                    Name = f.Name
                }).First());

        private static readonly Func<SimplyEntities, string, IEnumerable<PrintMethodDO>> GetPrintMethodsByMediaTypeQuery =
            CompiledQuery.Compile<SimplyEntities, string, IEnumerable<PrintMethodDO>>((ctx, mediaType) => 
                (from m in ctx.PrintMethod 
                from t in m.PrintMediaTypes where t.MediaTypeCode.Equals(mediaType)
                select new PrintMethodDO()
                {
                    Code = m.MethodCode,
                    BothSide = m.BothSide,
                    Description = m.LocaleDescKey,
                    Name = m.LocaleName,
                    Duration = m.Duration,
                    AvailableFrom = m.AvailableFrom
                }));


        private static readonly Func<SimplyEntities, string, PrintMediaDO> GetPrintMediaByCodeQuery =
            CompiledQuery.Compile<SimplyEntities, string, PrintMediaDO>((ctx, mediaCode) =>
                (from p in ctx.PrintMedia
                 where p.MediaCode.Equals(mediaCode)
                 select new PrintMediaDO()
                 {
                     Code = p.MediaCode,
                     DefaultPrintMethod = new PrintMethodDO() { Code = p.DefaultPrintMethod.MethodCode },
                     Description = p.LocaleDescKey,
                     Name = p.Name,
                     Name = p.LocaleName,
                     Type = new PrintMediaTypeDO(){Code = p.PrintMediaTypes.MediaTypeCode},
                     Weight = p.WeightGr.HasValue ? p.WeightGr.Value : 0,
                     AvailableFrom = p.AvailableFrom
                 }).First());

         */
        #endregion
    }
}
